package stu.lee.stu.lee.core.common.Utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class GetJedis {
    private GetJedis() {
    }

    public static synchronized Jedis getJedis() {

        Jedis jedis = buildJedisPool().getResource();
        jedis.auth("root");
        return jedis;
    }

    public static synchronized JedisPool buildJedisPool() {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMinIdle(50);
        config.setMaxIdle(3000);
        JedisPool jedisPool = new JedisPool(config,
                "localhost", 6379);
        return jedisPool;
    }
}